package cn.shyouchi.wuguanjia.android.api.notice;

import android.content.Context;

import java.util.Map;

import cn.shyouchi.wuguanjia.android.api.ClientProvider;
import cn.shyouchi.wuguanjia.android.api.UserStorageProvider;
import cn.shyouchi.wuguanjia.android.components.storage.UserStorage;
import cn.shyouchi.wuguanjia.android.model.BaseRequestResult;
import cn.shyouchi.wuguanjia.android.model.BaseResult;
import cn.shyouchi.wuguanjia.android.ui.home.security.thread.me.NoticeState;
import rx.Observable;

/**
 * Created by Eenie on 2017/3/13 at 16:49
 * Email: 472279981@qq.com
 * Des:
 */

public class NoticeApi {
    NoticeService mService;
    Context mContext;

    public NoticeApi(Context context) {
        this.mContext = context;
        UserStorage mUserStorage = UserStorageProvider.Default();
        mService = ClientProvider.getDefaultClient().getRetrofit(mUserStorage).create(NoticeService.class);
    }


    /**
     * 获取提醒的状态
     * 0、考勤提醒
     * 1、报岗提醒
     * 2、巡检提醒
     *
     * @param type
     * @return
     */
    public Observable<BaseRequestResult<NoticeState>> getNoticeSignState(int type) {
        String path;
        if (type == 0) {
            path = "AttendanceList";
        } else if (type == 1) {
            path = "PostList";
        } else {
            path = "InspectionList";
        }
        return mService.getNoticeSignState(path);
    }
    /**
     * 改变提醒的状态
     * 0、考勤
     * 1、报岗
     * 2、巡检
     *
     * @param type
     * @return
     */
    public Observable<BaseResult> ToggleNoticeState(int type) {
        String path;
        if (type == 0) {
            path = "AttendanceOpen";
        } else if (type == 1) {
            path = "PostOpen";
        } else {
            path = "InspectionOpen";
        }
        return mService.ToggleNoticeState(path);
    }



    public Observable<BaseResult> saveNoticeState(int type, Map<String, Object> params) {
        String path;
        if (type == 0) {
            path = "AttendanceAdd";
        } else if (type == 1) {
            path = "PostAdd";
        } else {
            path = "InspectionAdd";
        }
        return mService.saveNoticeState(path, params);
    }





}
